<?php
/*
	[UCenter Home] (C) 2007-2008 Comsenz Inc.
	$Id: space_mtag.php 13083 2009-08-10 09:35:23Z xupeng $
*/

if(!defined('IN_UCHOME')) {
	exit('Access Denied');
}

$id = empty($_GET['id']) ? "0" : $_GET['id'];
$uids = empty($_GET['uid']) ? "0" : $_GET['uid'];
if($id == 0){

$perpage = 10;
$page = intval($_GET['page']);
if($page < 1) $page = 1;
$start = ($page-1)*$perpage;

// 信息列表
if($uids){
	$wherestr =" where uid = ".$uids;
	$theurl = "space.php?do=rentship&uid=".$uids;
}else{
	$wherestr = " where 1";
	$theurl = "space.php?do=rentship";
}
	
$countsql = "SELECT COUNT(*) FROM ".tname('rentship').$wherestr;
$count = $_SGLOBAL['db']->result($_SGLOBAL['db']->query($countsql), 0);

	$sql = "SELECT * FROM ".tname('rentship').$wherestr." order by id desc LIMIT $start,$perpage";
	$theurl = "space.php?do=rentship";
	if($count) {
		$query = $_SGLOBAL['db']->query($sql);

		while ($value = $_SGLOBAL['db']->fetch_array($query)) {
			$value['nature']=empty($value['nature']) ? '未知' : lang('nature'.$value['nature']);
			$value['inout']=empty($value['inout']) ? '未知' : lang('inout'.$value['inout']);
			$value['shape']=empty($value['shape']) ? '未知' : lang('shape'.$value['shape']);
			$value['starttime'] = date('m-d H:i',$value['starttime']);
			$value['endtime'] = date('m-d H:i',$value['endtime']);
			$list[] = $value;
		}
			$multi = multi($count, $perpage, $page, $theurl);

	}
	include_once template("space_rentship_list");
}else{
	
	$sql = "SELECT * FROM ".tname('rentship')." where id =".$id;
	$query = $_SGLOBAL['db']->query($sql);

	while($value = $_SGLOBAL['db']->fetch_array($query)) {
			$value['nature']=empty($value['nature']) ? '未知' : lang('nature'.$value['nature']);
			$value['inout']=empty($value['inout']) ? '未知' : lang('inout'.$value['inout']);
			$value['shape']=empty($value['shape']) ? '未知' : lang('shape'.$value['shape']);
			$value['starttime'] = date('Y-m-d H:i',$value['starttime']);
			$value['endtime'] = date('Y-m-d H:i',$value['endtime']);
			$cargo = $value;
		}
	
	$sql = "SELECT * FROM ".tname('info_message')." where touid =".$space['uid']." and infoid =".$id;
	$query = $_SGLOBAL['db']->query($sql);

	while($value = $_SGLOBAL['db']->fetch_array($query)) {
			$value['dateline'] = date('Y-m-d H:i',$value['dateline']);
			$info[] = $value;
		}

	include_once template("space_rentship");
}

?>